<template>
  <b-col v-if="type == 1&&text!=null" class="pl-0 mt-2">
    <span style="border-left: 4px solid rgb(134, 134, 134);" v-if="this.info.source[0] == 'c'" class="commentHim text-muted">
      {{info.receiver.name}}:{{text.content}}
    </span>
    <span style="border-left: 4px solid rgb(134, 134, 134);" v-if="this.info.source[0] == 'a'" class="commentHim text-muted">
      文章 : {{text.title}}
    </span>
    <span style="border-left: 4px solid rgb(134, 134, 134);" v-if="this.info.source[0] == 'd'" class="commentHim text-muted">
      动态 : {{text.content}}
    </span>
  </b-col>
  <b-col v-else-if="type == 0&&text!=null" class="pl-0 mt-2">
    <span style="border-left: 4px solid rgb(134, 134, 134);" v-if="info.type == 'article'" class="commentHim text-muted">
      文章 : {{text.title}}
    </span>
    <span style="border-left: 4px solid rgb(134, 134, 134);" v-else-if="info.type == 'dynamic'" class="commentHim text-muted">
      动态 : {{text.content}}
    </span>
    <span style="border-left: 4px solid rgb(134, 134, 134);" v-else class="commentHim text-muted">
      {{text.user.name}}:{{text.content}}
    </span>
  </b-col>
</template>
<script>
import httpIssue from '@/utils/httpIssue'
export default {
  props: {
    info: Object,
  },
  data() {
    return {
      text: null,
      //二次查询的信息
      type: null,
    }
  },
  methods: {
    message(type) {
      if (type == 'd') {
        httpIssue.getEntity(this.info.source, "dynamic").then((res) => {
          this.text = res;
        });
      } else if (type == 'c') {
        httpIssue.getEntity(this.info.source, "comment").then((res) => {
          this.text = res
        });
      } else if (type == 'a') {
        httpIssue.getEntity(this.info.source, "article").then((res) => {
          this.text = res
        });
      }
    }
  },
  mounted() {
    if ((this.info.source != 'null' || this.info.type == 'state') && this.info.source != undefined) {
      this.type = 1;
      //代表是message类型的信息
      this.message(this.info.source[0]);
    } else {
      this.type = 0;
      if (this.info.type != "comment" && this.info.type != "article" && this.info.type != "dynamic") {
        httpIssue.getEntity(this.info.type, null).then((res) => {
          this.text = res
          return
        });
        return
      }
      httpIssue.getEntity(this.info.commentId, this.info.type).then((res) => {
        this.text = res
      });
    }

  }
}
</script>
<style scoped>
</style>
